package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.MarketCategory;
import com.cskaoyan.bean.MarketGoods;
import com.cskaoyan.bean.leihao.vo.GoodsCategoryVo;
import com.cskaoyan.bean.leihao.vo.HotGoodsListDTO;
import com.cskaoyan.bean.leihao.vo.WxGoodsDetailVo;
import com.cskaoyan.bean.leihao.vo.WxGoodsListVo;
import com.cskaoyan.bean.param.CommonData;
import com.cskaoyan.mapper.MarketGoodsMapper;
import com.cskaoyan.service.CategoryService;
import com.cskaoyan.service.GoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther: leihao
 * @Date: Created in 15:51 2022/6/29
 */
@RestController
@RequestMapping("wx/goods")
public class GoodsWxController {
    @Autowired
    GoodsService goodsService;
    @Autowired
    CategoryService categoryService;
    @RequestMapping("count")
    public BaseRespVo count(){
        Integer count = goodsService.getGoodsCount();
        return BaseRespVo.ok(count);
    }
    @RequestMapping("category")
    public BaseRespVo category(Integer id){
        GoodsCategoryVo goodsCategoryVo = categoryService.getCategoryByPid(id);
        return BaseRespVo.ok(goodsCategoryVo);
    }
    @RequestMapping("list")
    public BaseRespVo list(Integer brandId,String keyword,Integer categoryId,Integer page,Integer limit){
        WxGoodsListVo goodsListVo = categoryService.getCategoryListByCategoryId(brandId,keyword,categoryId,page, limit);
        return BaseRespVo.ok(goodsListVo);
    }
    @RequestMapping("detail")
    public BaseRespVo detail(Integer id){
        WxGoodsDetailVo goodsDetailVo = goodsService.getWxGoodsDetail(id);
        return BaseRespVo.ok(goodsDetailVo);
    }
    @RequestMapping("related")
    public BaseRespVo related(Integer id){
        CommonData<HotGoodsListDTO> goodsListDTOCommonData = goodsService.getRelated(id);
        return BaseRespVo.ok(goodsListDTOCommonData);
    }
}
